package com.luoye.lj.wstool.web;

import com.luoye.lj.wstool.generator.ICodeGenerator;
import com.luoye.lj.wstool.web.entity.WebtEntity;
import com.luoye.lj.wstool.web.entity.WebtField;

/*
 * Created with IntelliJ IDEA.
 * User: Dave Liu
 * Date: 2016/7/7
 * Time: 15:45
 * To change this template use File | Settings | File Templates.
 */
public class JspEditTargetCodeGenerator implements ICodeGenerator {
    private WebtEntity webtEntity;

    public JspEditTargetCodeGenerator(WebtEntity webtEntity) {
        this.webtEntity = webtEntity;
    }

    @Override
    public String codeGenerate() {
        String code="";
        if(this.webtEntity!=null){
            if(this.webtEntity.getFieldList()!=null){
                for(WebtField webtField:this.webtEntity.getFieldList()){
                    if("id".equals(webtField.getFieldName())){
                        continue;
                    }
                    code+="                                     <div class=\"form-group\">\n" +
                            "                                        <label class=\"col-sm-4 control-label\">"+webtField.getDescription()+"：</label>\n" +
                            "                                        <div class=\"col-sm-8\">\n" +
                            "                                            <input type=\"text\" class=\"form-control\" id=\""+webtField.getFieldName()+"_edit\" placeholder=\"\"\n" +
                            "                                                   role=\"button\" data-toggle=\"popover\" data-placement=\"bottom\"\n" +
                            "                                                   data-trigger=\"focus\" data-content=\"\">\n" +
                            "                                        </div>\n" +
                            "                                    </div>\n";
                }
            }
        }
        return code;
    }
}
